use crossterm::{
  event::{read, Event::Key, KeyEvent},
  Result,
};

use crate::output;

pub fn editor_read_key() -> Result<KeyEvent> {
  loop {
    if let Ok(event) = read() {
      if let Key(key_event) = event {
        return Ok(key_event);
      }
    } else {
      output::die("read");
      break;
    }
  }
  unreachable!()
}
